home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / text / edit / vim60rt.lha / Vim / vim60 / syntax / nroff.vim < prev    next >
Encoding:
Text File  |  2001-05-11  |  7.2 KB  |  214 lines

  1. " VIM syntax file
  2. " Language:    nroff / groff
  3. " Maintainer:    Jérôme Plût <Jerome.Plut@ens.fr>
  4. " URL:        http://www.eleves.ens.fr:8080/home/plut/nroff.vim
  5. " Last Change:    2001 May 10
  6. "
  7. " {{{1 Preamble
  8. " groff (GNU troff) behaves slightly differently from groff; it allows
  9. " long names being specified between brackets: for instance, \[hy] is
  10. " equivalent to \(hy.
  11. " This file handle both syntaxes, depending on the value of 'filetype'.
  12.  
  13. " For version 5.x: Clear all syntax items
  14. " For version 6.x: Quit when a syntax file was already loaded
  15. if version < 600
  16.   syntax clear
  17. elseif exists("b:current_syntax")
  18.   finish
  19. endif
  20.  
  21.  
  22. if exists("nroff_space_errors")
  23.   syn match nroffError /\s\+$/
  24. endif
  25.  
  26. " {{{1 Escape sequences
  27. " ------------------------------------------------------------
  28.  
  29. syn match nroffEscChar /\\[CN]/ nextgroup=nroffEscCharArg
  30. syn match nroffEscape /\\[*gnYV]/ nextgroup=nroffEscRegPar,nroffEscRegArg
  31. syn match nroffEscape /\\s[+-]\=/ nextgroup=nroffSize
  32. syn match nroffEscape /\\[$AbDfhlLRvxXZ]/ nextgroup=nroffEscPar,nroffEscArg
  33.  
  34. syn match nroffEscRegArg /./ contained
  35. syn match nroffEscRegArg2 /../ contained
  36. syn match nroffEscRegPar /(/ contained nextgroup=nroffEscRegArg2
  37. syn match nroffEscArg /./ contained
  38. syn match nroffEscArg2 /../ contained
  39. syn match nroffEscPar /(/ contained nextgroup=nroffEscArg2
  40. syn match nroffSize /\((\d\)\=\d/ contained
  41.  
  42. syn region nroffEscCharArg start=/'/ end=/'/ contained
  43. syn region nroffEscArg start=/'/ end=/'/ contained contains=nroffEscape,@nroffSpecial
  44.  
  45. if exists("b:nroff_is_groff")
  46.   syn region nroffEscRegArg matchgroup=nroffEscape start=/\[/ end=/\]/ contained oneline
  47.   syn region nroffSize matchgroup=nroffEscape start=/\[/ end=/\]/ contained
  48. endif
  49.  
  50. syn match nroffEscape /\\[adprtu{}]/
  51. syn match nroffEscape /\\$/
  52. syn match nroffEscape /\\\$[@*]/
  53.  
  54. " {{{1 Strings and special characters
  55. " ------------------------------------------------------------
  56.  
  57. syn match nroffSpecialChar /\\[\\eE?!-]/
  58. syn match nroffSpace  "\\[&%~|^0)/,]"
  59. syn match nroffSpecialChar /\\(../
  60. if exists("b:nroff_is_groff")
  61.   syn match nroffSpecialChar /\\\[[^]]*]/
  62.   syn region nroffPreserve matchgroup=nroffSpecialChar start=/\\?/ end=/\\?/ oneline
  63. endif
  64. syn region nroffPreserve matchgroup=nroffSpecialChar start=/\\!/ end=/$/ oneline
  65.  
  66. syn cluster nroffSpecial contains=nroffSpecialChar,nroffSpace
  67.  
  68.  
  69. syn region nroffString start=/"/ end=/"/ skip=/\\$/ contains=nroffEscape,@nroffSpecial contained
  70. syn region nroffString start=/'/ end=/'/ skip=/\\$/ contains=nroffEscape,@nroffSpecial contained
  71.  
  72.  
  73. " {{{1 Numbers and units
  74. " ------------------------------------------------------------
  75. syn match nroffNumBlock /[0-9.]\a\=/ contained contains=nroffNumber
  76. syn match nroffNumber /\d\+\(\.\d*\)\=/ contained nextgroup=nroffUnit,nroffBadChar
  77. syn match nroffNumber /\.\d\+)/ contained nextgroup=nroffUnit,nroffBadChar
  78. syn match nroffBadChar /./ contained
  79. syn match nroffUnit /[icpPszmnvMu]/ contained
  80.  
  81.  
  82. " {{{1 Requests
  83. " ------------------------------------------------------------
  84.  
  85. " Requests begin with . or ' at the beginning of a line, or after .if or
  86. " .ie.
  87.  
  88. syn match nroffReqLeader /^[.']/ nextgroup=nroffReqName skipwhite
  89. syn match nroffReqLeader /[.']/ contained nextgroup=nroffReqName skipwhite
  90. if exists("b:nroff_is_groff")
  91. " GNU troff allows long request names
  92.   syn match nroffReqName /[^\t \\\[?]\+/ contained nextgroup=nroffReqArg
  93. else
  94.   syn match nroffReqName /[^\t \\\[?]\{1,2}/ contained nextgroup=nroffReqArg
  95. endif
  96. syn region roffReqArg start=/\S/ skip=/\\$/ end=/$/ contained contains=nroffEscape,@nroffSpecial,nroffString,nroffError,nroffNumBlock,nroffComment
  97.  
  98. " {{{2 Conditional: .if .ie .el
  99. syn match nroffReqName /\(if\|ie\)/ contained nextgroup=nroffCond skipwhite
  100. syn match nroffReqName /el/ contained nextgroup=nroffReqLeader skipwhite
  101. syn match nroffCond /\S\+/ contained nextgroup=nroffReqLeader skipwhite
  102.  
  103. " {{{2 String definition: .ds .as
  104. syn match nroffReqname /[da]s/ contained nextgroup=nroffDefIdent skipwhite
  105. syn match nroffDefIdent /\S\+/ contained nextgroup=nroffDefinition skipwhite
  106. syn region nroffDefinition matchgroup=nroffSpecialChar start=/"/ matchgroup=NONE end=/\\"/me=e-2 skip=/\\$/ start=/\S/ end=/$/ contained contains=nroffDefSpecial
  107. syn match nroffDefSpecial /\\$/ contained
  108. syn match nroffDefSpecial /\\\((.\)\=./ contained
  109.  
  110. if exists("b:nroff_is_groff")
  111.   syn match nroffDefSpecial /\\\[[^]]*]/ contained
  112. endif
  113.  
  114. " {{{2 Macro definition: .de .am, also diversion: .di
  115. syn match nroffReqName /\(d[ei]\|am\)/ contained nextgroup=nroffIdent skipwhite
  116. syn match nroffIdent /[^[?( \t]\+/ contained
  117. if exists("b:nroff_is_groff")
  118.   syn match nroffReqName /als/ contained nextgroup=nroffIdent skipwhite
  119. endif
  120.  
  121. " {{{2 Register definition: .rn .rr
  122. syn match nroffReqName /[rn]r/ contained nextgroup=nroffIdent skipwhite
  123. if exists("b:nroff_is_groff")
  124.   syn match nroffReqName /\(rnn\|aln\)/ contained nextgroup=nroffIdent skipwhite
  125. endif
  126.  
  127.  
  128. " {{{1 eqn/tbl/pic
  129. " ------------------------------------------------------------
  130. " XXX: write proper syntax highlight for eqn / tbl / pic ?
  131.  
  132. syn region nroffEquation start=/^\.\s*EQ/ end=/^\.\s*EN/
  133. syn region nroffTable start=/^\.\s*TB/ end=/^\.\s*TE/
  134. syn region nroffPicture start=/^\.\s*PB/ end=/^\.\s*PE/
  135.  
  136. " {{{1 Comments
  137. " ------------------------------------------------------------
  138.  
  139. syn region nroffIgnore start=/^[.']\s*ig/ end=/^['.]\s*\./
  140. syn match nroffComment /\(^[.']\s*\)\=\\".*/ contains=nroffTodo
  141. syn match nroffComment /^'''.*/ contains=nroffTodo
  142. if exists("b:nroff_is_groff")
  143.   syn match nroffComment "\\#.*$" contains=nroffTodo
  144. endif
  145. syn keyword nroffTodo TODO XXX FIXME contained
  146.  
  147. " {{{1 Hilighting
  148. " ------------------------------------------------------------
  149.  
  150. " Define the default highlighting.
  151. " For version 5.7 and earlier: only when not done already
  152. " For version 5.8 and later: only when an item doesn't have highlighting yet
  153. if version >= 508 || !exists("did_nroff_syn_inits")
  154.   if version < 508
  155.     let did_nroff_syn_inits = 1
  156.     command -nargs=+ HiLink hi link <args>
  157.   else
  158.     command -nargs=+ HiLink hi def link <args>
  159.   endif
  160.  
  161. HiLink nroffEscChar    nroffSpecialChar
  162. HiLink nroffEscCharAr    nroffSpecialChar
  163. HiLink nroffSpecialChar    SpecialChar
  164. HiLink nroffSpace    Delimiter
  165.  
  166. HiLink nroffEscRegArg2    nroffEscRegArg
  167. HiLink nroffEscRegArg    nroffIdent
  168.  
  169. HiLink nroffEscArg2    nroffEscArg
  170. HiLink nroffEscPar    nroffEscape
  171.  
  172. HiLink nroffEscRegPar    nroffEscape
  173. HiLink nroffEscArg    nroffEscape
  174. HiLink nroffSize    nroffEscape
  175. HiLink nroffEscape    Preproc
  176.  
  177. HiLink nroffIgnore    Comment
  178. HiLink nroffComment    Comment
  179. HiLink nroffTodo    Todo
  180.  
  181. HiLink nroffReqLeader    nroffRequest
  182. HiLink nroffReqName    nroffRequest
  183. HiLink nroffRequest    Statement
  184. HiLink nroffCond    PreCondit
  185. HiLink nroffDefIdent    nroffIdent
  186. HiLink nroffIdent    Identifier
  187.  
  188. HiLink nroffEquation    PreProc
  189. HiLink nroffTable    PreProc
  190. HiLink nroffPicture    PreProc
  191.  
  192. HiLink nroffNumber    Number
  193. HiLink nroffBadChar    nroffError
  194. HiLink nroffError    Error
  195.  
  196. HiLink nroffPreserve    String
  197. HiLink nroffString    String
  198. HiLink nroffDefinition    String
  199. HiLink nroffDefSpecial    Special
  200.  
  201.   delcommand HiLink
  202. endif
  203.  
  204. " I recommend using for nroffDefinition an highlight that shows spaces,
  205. " since nroff includes them in the string, for instance:
  206. " hi def nroffDefinition term=italic cterm=italic gui=reverse
  207. " hi def nroffDefSpecial term=italic,bold cterm=italic,bold gui=reverse,bold
  208.  
  209. let b:current_syntax = "nroff"
  210.  
  211. " }}}1
  212. " vim: set ts=8 sw=2:
  213. " vim600: set fdm=marker fdl=2:
  214.